package com.come4loves.game.module.fight.action;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import com.come4loves.game.module.fight.model.FightCard;
import com.come4loves.game.proto.BattleProto;
import com.google.protobuf.GeneratedMessage.Builder;

public class SkillAction extends Action {
	private List<Integer> targetIds = new ArrayList<Integer>();
	public SkillAction(FightCard src, FightCard... target) {
		super(src.getId());
		for (FightCard fightCard : target) {
			targetIds.add(fightCard.getId());
		}
	}
	public SkillAction(FightCard src) {
		super(src.getId());
	}
	public SkillAction(FightCard src, Collection<FightCard> target) {
		super(src.getId());
		for (FightCard fightCard : target) {
			addTarget(fightCard);
		}
	}
	public void addTarget(FightCard target) {
		this.targetIds.add(target.getId());
	}
	public List<Integer> getTargetIds() {
		return targetIds;
	}

	@Override
	public Builder<?> toProtocolBufferBuilder() {
		BattleProto.SkillAction.Builder builder = BattleProto.SkillAction.newBuilder();
		builder.setSrcId((int) this.id);
		builder.addAllTargets(targetIds);
		return builder;
	}

}
